package djboom.materials.display.test {
	import djboom.materials.state.Font;

	import org.casalib.display.CasaSprite;
	import org.casalib.display.CasaTextField;

	import flash.events.Event;
	import flash.text.AntiAliasType;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	/**
	 * .
	 * <br>
	 * 
	 * @author DJ BooM 
	 * @since 08.04.2010
	 * 
	 */

	public class Question extends CasaSprite {

		// ----------------------------------------------------------------------------
		// Константы класса.
		// ----------------------------------------------------------------------------

		private static const TITLE_TFORMAT:TextFormat = new TextFormat(Font.MYRIAD_PRO_COND, 26, 0x709402, true, true);

		// ----------------------------------------------------------------------------
		// Свойства класса.
		// ----------------------------------------------------------------------------

		private var _questionField:CasaTextField;

		// ----------------------------------------------------------------------------
		// Конструктор.
		// ----------------------------------------------------------------------------

		public function Question(questionText:String) {
			super();
			
			_questionField = new CasaTextField();
			_questionField.embedFonts = true;
			_questionField.antiAliasType = AntiAliasType.ADVANCED;
			_questionField.autoSize = TextFieldAutoSize.LEFT;          
			_questionField.defaultTextFormat = TITLE_TFORMAT;
			_questionField.text = questionText;
			_questionField.selectable = false;
			_questionField.mouseEnabled = false;
			addChild(_questionField);
			
			addEventListener(Event.REMOVED_FROM_STAGE, clearPage);
		}	 

		// ----------------------------------------------------------------------------
		// Методы класса.
		// ----------------------------------------------------------------------------

		private function clearPage(event:Event):void {
			_questionField.destroy();
			_questionField = null;
		}

		// ----------------------------------------------------------------------------
		// Публичные методы.
		// ----------------------------------------------------------------------------
		
		// ----------------------------------------------------------------------------
		// Публичные свойства.
		// ----------------------------------------------------------------------------

		public function set questionText(questionText:String):void {
			_questionField.text = questionText;
		}
	}
}
